<template>
	<div>
		h5login
	</div>
</template>

<script>
	export default {
		onLoad(options) {
			console.log(options)
			const that = this 
			const code = options?.code
			uni.request({
				url:'http://192.168.1.188:8080/m.api',
				method:'POST',
				data:{
					"_gp":"user",
					"_mt":"thirdPartLogin",
					loginType:3,
					raw:code
				},
				header:{
					"Content-Type":"application/x-www-form-urlencoded"
				},
				success:(res)=>{
					console.log(res)
					let data = res.data
					if(200 === data.errno){
						let user = res.data.data
						uni.setStorageSync("user",JSON.stringify(user))
						uni.showToast({
							title:"登录成功"
						})
						uni.switchTab({
							url:"/pages/index/index"
						})
					}else{
						uni.showToast({
							title:data.errmsg
						})
						uni.redirectTo({
							url:"/pages/public/login"
						})
					}
				},
				fail:(err)=>{
					uni.showToast({
						title:err,
						icon:'none'
					})
				}
			})
		}
	}
</script>
<style>
</style>